<template>
  <div></div>
</template>

<script>
export default {
  props:{},
  computed: {
    html_1:function(){
      let msg = this.msg;
      let html = msg.map((v)=>{
        if( RegExp('基本面：|技术面：').test(v) ){
          return `<p><br></p><p>${v}</p>`;
        }
        return `<p>${v}</p>`
      }).join('');
      return html;
    },
    html_2:function(){
      let txt = this.RiskStatement.join('')
      return `<p><br></p><p><small>${txt}</small></p>`
    }
  },
  data(){
    return {
      loading:false,
      RiskStatement:[
        '以上为首席投顾：陈放【证书号A0380619120001】',
        '风险提示：以上分析为顶点财经投顾老师团队分析判断，不做具体承诺保证。',
        '股市有风险，投资需谨慎',
        '资讯提供：杭州顶点财经网络传媒有限公司 证书：913301087996770893',
      ],
      msg: [],
      buyAdvice: "买入建议",
      holdAdvice: "持有建议",
      sellAdvice: "卖出建议"
    }
  },
  methods:{
    isStockCode:function(code){
      return new RegExp(/\d{6}/).test(code)
    },
    reset(){
      this.msg.splice(0,this.msg.length);
      this.buyAdvice = "";
      this.holdAdvice = "";
      this.sellAdvice = "";
    },
    sharesQuery(stockCode){
      this.loading = true;
      return this.$api.getAiAnswer({
        stockCode:stockCode
      }).then((res)=>{
        this.loading = false;
        if(res.data.code == 200){
          console.log(res)
          this.loading = false;
          this.msg = res.data.data.msg.split('\r\n');
          this.buyAdvice = _.get(res.data.data,'buyAdvice','买入建议');
          this.holdAdvice = _.get(res.data.data,'holdAdvice','持有建议');;
          this.sellAdvice = _.get(res.data.data,'sellAdvice','卖出建议');
        }
        if(res.data.code == 500){
          this.$message({
            type:'error',
            message:'服务器正在开小差，请稍后重试'
          })
        }
        return Promise.resolve(res)
      })
    },
    copy(){
      let txt = this.html_1 + this.html_2;
      this.$store.commit('setDraftView','text');
      this.$store.commit('setDraft',{type:'clipboard',obj:txt})
    },
  },
  mounted(){
    
  }
}
</script>

<style>

</style>